FROM ubuntu:24.04
RUN echo 'root:root' |chpasswd

ENV TZ=Asia/Shanghai

# 备份配置文件
RUN cp -a /etc/apt/sources.list /etc/apt/sources.list.bak
# 替换阿里镜像源
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
RUN sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
# 替换华为镜像源
#RUN sed -i 's/archive.ubuntu.com/mirrors.huaweicloud.com/g' /etc/apt/sources.list
#RUN sed -i 's/security.ubuntu.com/mirrors.huaweicloud.com/g' /etc/apt/sources.list
RUN apt-get clean

# RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C

RUN apt-get update \
    && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
    && apt-get install -y tzdata vim wget curl openssh-server openssl supervisor \
    build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev \
    librsvg2-dev graphicsmagick imagemagick unzip git locales iputils-ping \
    net-tools telnet file

RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

ENV LANG=en_US.UTF-8

RUN curl https://get.volta.sh | bash

RUN cd /opt \
    && wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
    && dpkg -i google-chrome* \
    && apt-get -f install -y

RUN mkdir -p /var/run/sshd

RUN sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -ri 's/^#?PasswordAuthentication\s+.*/PasswordAuthentication no/g' /etc/ssh/sshd_config
RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config

RUN mkdir -p /root/.ssh
RUN touch /root/.ssh/authorized_keys
RUN echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFTmRn2jUguS4uRBFNR8vOCwLh5FBjW5uQHCJQEV3vMv ed25519 pipidocker" >> /root/.ssh/authorized_keys

RUN touch /etc/supervisor/conf.d/sshd.conf
RUN echo "[program:SSHD]" >> /etc/supervisor/conf.d/sshd.conf
RUN echo "command=/usr/sbin/sshd -D" >> /etc/supervisor/conf.d/sshd.conf
RUN echo "autostart=true" >> /etc/supervisor/conf.d/sshd.conf
RUN echo "autorestart=true" >> /etc/supervisor/conf.d/sshd.conf
RUN echo "user=root" >> /etc/supervisor/conf.d/sshd.conf

RUN apt-get clean \
    && apt-get autoclean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

EXPOSE 22

CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"]
